import java.util.Scanner;
//Class Animal
abstract class Animal{
	protected String name;
	//phuong thuc cho dong vat an
	protected void eat(Food food, int m){
		int x=food.getMass();
		if(food.getMass()>=m){
			food.setMass(x-m); 
			//System.out.println("Con "+this.name+" moi lan an "+ m + " don vi thuc an");
		}
		else System.out.println("\t Khong du " + m + " thuc an cho con vat ");
	}
	//phuong thuc duoc nap chong
	protected  abstract Animal havaBaby(String childName);
	//Phuong thuc nhap vao ten cua con vat
	public void scaninfo(){
		Scanner nhap=new Scanner(System.in);
		if(this instanceof Bird){
			System.out.print("\t Nhap ten cua con chim: ");
			name=nhap.nextLine();			
		}else if(this instanceof Tiger){
			System.out.print("\t Nhap ten cua con ho: ");
			name=nhap.nextLine();
		}else if(this instanceof Fish){
			System.out.print("\t Nhap ten cua con ca: ");
			name=nhap.nextLine();
		}
	}	
	public String getName(){
		return this.name;
	}
}
//Class Fish
class Fish extends Animal{
	//boi
	public void swim(){
		System.out.println("\t Con ca " + this.name+" thi biet boi");
	}
	//lan
	public void dive(){
		System.out.println("\t Con ca " + this.name+" biet lan");
	}
	//chong phuong thuc sinh con
	public Fish havaBaby(String name){
		Fish fchild =new Fish(name);
		return fchild;
	}
	//ham tao mac dinh
	public Fish(){}
	//ham tao co tham so
	public Fish(String str){
		this.name=str;
	}
}
//Class Bird
class Bird extends Animal{
	//bay
	public void fly(){
		System.out.println("\t Con chim " + this.name+" biet bay");
	}
	//chong phuong thuc sinh con
	public Bird havaBaby(String name){
		Bird fchild =new Bird(name);
		return fchild;
	}
	//ham tao mac dinh
	public Bird(){}
	//ham tao co tham so
	public Bird(String str){
		this.name=str;
	}
}
//Class Tiger
class Tiger extends Animal{ 
	//chay
	public void run(){
		System.out.println("\t Con ho " + this.name+" biet chay");
	}
	//nap chong phuong thuc sinh con 
	public Tiger havaBaby(String name){
		Tiger fchild =new Tiger(name);
		return fchild;
	}
	//ham tao mac dinh
	public Tiger(){}
	//ham tao sao chep
	public Tiger(String str){
		this.name=str;
	}
}
//class Food
class Food{
	private int mass;
	//ham tao mac dinh
	public Food(){}
	//ham tao sao chep
	public Food(int m){
		mass=m;
	}
	//lay ra luong thuc an
	public int getMass(){
		return mass;
	}
	//gan luong thuc an
	public void setMass(int x){
		mass=x;
	}
}

